package com.jdk.thread.action.room;

import com.jdk.thread.action.execaction.Executor;

/**
 * @Description :
 * @FileName: RoomMgr.java
 * @Author :WeiHui.Zhang
 * @Data : 2016年2月2日 下午6:17:06
 * @Version:V1.00
 */
public class RoomMgr {

	private static Executor executor;
	private static Room[] rooms;// 战役房间列表
	public static final int MAX_ROOM = 5000;

	public static boolean init() {
		int corePoolSize = 8;
		int maxPoolSize = 16;
		int keepAliveTime = 5;
		int cacheSize = 64;
		executor = new Executor(corePoolSize, maxPoolSize, keepAliveTime, cacheSize, "roomMgr", null);
		//
		// stateOfMatch = new MatchStateSleep();
		// stateOfVehicle = new MatchStateSleepOfVehicle();
		// waitingRoom = new WaitingRoom();
		// matchingRooms = new Hashtable<Integer, Room>();
		rooms = new Room[MAX_ROOM];
		for (int i = 0; i < MAX_ROOM; i++) {
			rooms[i] = new Room(i + 1);
		}
		// isLocalMatch = false;
		long currentMillis = System.currentTimeMillis();
		executor.enDelayQueue(new CampaignUpdateAction(executor.getDefaultQueue(), currentMillis, 60 * 1000));
		// executor.enDelayQueue(new
		// MatchStartAction(executor.getDefaultQueue(), currentMillis,
		// MATCH_TIME_INTERVAL));
		return true;
	}

	public static Executor getExeccutor() {
		return executor;
	}
}
